First model ============ A three-equation New Keynesian model, end to end, in fewer than twenty lines. The model file --------------- Save the following as ``nk.rs``:: @endogenous x pi i @exogenous eps_m @parameters beta sigma kappa phi_pi phi_y rho_m std_eps_m @model x{t} = x{t+1} - (1/sigma)*(i{t} - pi{t+1}); pi{t} = beta*pi{t+1} + kappa*x{t}; i{t} = phi_pi*pi{t} + phi_y*x{t} + std_eps_m*eps_m{t}; Build and solve ---------------- In MATLAB:: p = struct( ... 'beta', 0.99, ... 'sigma', 1.0, ... 'kappa', 0.30, ... 'phi_pi', 1.50, ... 'phi_y', 0.125, ... 'std_eps_m', 0.0025); m = dsge_model('nk.rs'); m = set(m, parameters = p); [m, retcode] = solve(m); assert(retcode == 0, decipher(retcode)); Inspect -------- :: print_solution(m); myirfs = irf(m, irf_periods = 20); plot(myirfs.eps_m.pi, LineWidth = 2); What just happened ------------------- - ``dsge_model(...)`` parsed ``nk.rs`` into a model object describing the state-space, with no class-specific metadata stashed away. ``dsge_model`` is the DSGE-shape factory; the VAR family has its own (``rfvar_model``, ``svar_model``, ``proxy_svar_model``, ``prfvar_model``, ``dsge_var_model``). - ``set(m, parameters = ...)`` bound numerical values to the declared parameters. The model file declared the model; this call parameterized it. See the *Modern architecture* chapter for why these are kept separate. - ``solve(m)`` ran the perturbation engine and returned the model with the solution attached. The retcode is always captured and checked. - ``irf`` returned a struct of time series objects (one per shock, one per variable). ``plot`` is overloaded for the time series type -- no need to extract the underlying numeric array. Next steps ----------- - *Modeling -> Model file language* for the full ``.rs`` grammar. - *Modeling -> Solving* for the solver options exposed on ``solve``. - *Modeling -> Estimation* for taking the model to data.